<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/25
 * Time: 14:29
 */
$redisClient = new swoole_redis;//Swoole\Redis

//异步连接redis
$redisClient->connect('127.0.0.1', 6379, function (swoole_redis $redisClient, $result) {
    echo "connect" . PHP_EOL;
    var_dump($result);

    //同步 redis (new Redis()->set('key',2));
    //异步redis
    /*$redisClient->set('tommy_1', time(), function (swoole_redis $redisClient, $result) {
        var_dump($result);
        $redisClient->close();
    });*/

    //get  这个result就是这个KEY在redis里的值
    /*$redisClient->get('tommy_1', function (swoole_redis $redisClient, $result) {
        var_dump($result);
        $redisClient->close();
    });*/

    //获取redis中所有的值 ,也可以模糊查询 *name* , na?? 可以查询类似firstname username name等
    $redisClient->keys('*',function (swoole_redis $redisClient, $result) {
        var_dump($result);
        $redisClient->close();
    });

});

echo "start" . PHP_EOL;